#include <stdio.h>

int main(void){
  char *path = "io.txt";
  FILE *file = fopen(path,"a+");
  if(file==NULL){
    printf("文件不存在\n");
  }else{
    printf("文件打开成功\n");
  }
  // 从文件读取字符串
  char name[10];
  int age=0;
  while(fscanf(file,"%s %d\r\n",name,&age)>=2){
    printf("%s %d\n",name,age);
  }
  
  int res = fclose(file);
  if(res!=0){
    printf("文件关闭失败\n");
    return -1;
  }
  printf("文件关闭成功\n");
  return 0;
}
